﻿package com.wandian.view.components.ui
{
	import com.wandian.ApplicationFacade;
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.InRoomPlayerDataProxy;
	import com.wandian.model.UserInfoProxy;
	import com.wandian.model.vo.*;
	import com.wandian.util.CLZButton;
	import com.wandian.util.CLZButtonFour;
	import com.wandian.util.CLZSlideTwo;
	import com.wandian.util.CLZTabBar;
	import com.wandian.util.GlowFilterManage;
	import com.wandian.util.TextControl;

	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import flash.events.*;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class SystemMessage extends Object
	{
		private var _mcPanel:Sprite;
		private var _arrList:Array;
		private var _numPage:int;
		private var _sumPage:int;
		private var _scrollChat:ScrollBarTxt;
		private var _arrNoticeTip:Array;

		public function SystemMessage(mcPanel:Sprite, arrMsgVo:Array, param3:int)
		{
			var _loc_5:int=0;
			var _loc_6:MessageVo=null;
			this._numPage=0;
			this._sumPage=arrMsgVo.length - 1;
			this._mcPanel=mcPanel;
			this._arrList=arrMsgVo;
			CLZButton.setButton(this._mcPanel["prev_btn"], GameData.tip["PREV_PAGE_1"]);
			CLZButton.setButton(this._mcPanel["next_btn"], GameData.tip["NEXT_PAGE_1"]);
			this._mcPanel["prev_btn"].addEventListener(MouseEvent.CLICK, this.onPrevHandler);
			this._mcPanel["next_btn"].addEventListener(MouseEvent.CLICK, this.onNextHandler);
			var _loc_4:*=GameData.getMovieClip("ScrollBarTxt");
			this._mcPanel.addChild(_loc_4);
			_loc_4.x=this._mcPanel["txt"].x + this._mcPanel["txt"].width;
			_loc_4.y=this._mcPanel["txt"].y;
			this._scrollChat=new ScrollBarTxt(this._mcPanel["txt"], _loc_4);
			this._arrNoticeTip=GameData.getNoticeTipXML();
			if (param3 == 0)
			{
				this.showTxt(this._arrList[this._numPage]);
			}
			else
			{
				_loc_5=0;
				while (_loc_5 < this._arrList.length)
				{

					_loc_6=this._arrList[_loc_5] as MessageVo;
					if (_loc_6.id == param3)
					{
						this.showTxt(this._arrList[_loc_5]);
						break;
					}
					_loc_5=_loc_5 + 1;
				}
			}
			return;
		}

		private function showTxt(msgVo:MessageVo):void
		{
			this._mcPanel["txt"].htmlText="\n<font size=\'26\' color=\'#ffff00\'><p align=\'center\'>" + msgVo.title + "</p></font>\n" + msgVo.content;
			this._mcPanel["txt"].htmlText=this._mcPanel["txt"].htmlText + "\n\n-------------------------------------------------------------------------------------------------------------------------------------";
			this._mcPanel["txt"].htmlText=this._mcPanel["txt"].htmlText + ("<font color=\'#ffffcc\'><p align=\'center\'>" + GameData.tip["SYSTEM_TIP"] + "：" + this._arrNoticeTip[Math.floor(Math.random() * this._arrNoticeTip.length)] + "</p></font>");
			this._mcPanel["pageNum_txt"].text=int((this._numPage + 1)) + "/" + int((this._sumPage + 1));
			return;
		}

		private function onPrevHandler(event:MouseEvent):void
		{
			this._numPage--;
			if (this._numPage < 0)
			{
				this._numPage=0;
//				this._mcPanel["prev_btn"].enable=false;
			}
//			if (this._numPage == this._sumPage - 1)
//			{
//				this._mcPanel["next_btn"].enable=true;
//			}
			this.showTxt(this._arrList[this._numPage]);
			return;
		}

		private function onNextHandler(event:MouseEvent):void
		{
			this._numPage++;
			if (this._numPage >= this._sumPage)
			{
				this._numPage=this._sumPage;
//				this._mcPanel["prev_btn"].enable=false;
			}
//			if (this._numPage == 1)
//			{
//				this._mcPanel["next_btn"].enable=true;
//			}
			this.showTxt(this._arrList[this._numPage]);
			return;
		}

	}
}
